<template>
  <Scroll :pullUpLoad="true" class="tabmenu" ref="scroll">
    <template>
      <div class="list">
        <div
          class="item"
          :class="{ active: index === myIndex }"
          v-for="(item, index) in categories"
          :key="index"
          @click="itemClick(index)"
        >
          {{ item.title }}
        </div>
      </div>
    </template>
  </Scroll>
</template>

<script>
import Scroll from '@/components/content/scroll/'
export default {
  name: 'tabmenu',
  components: {
    Scroll,
  },
  data() {
    return {
      myIndex: 0,
    }
  },
  props: {
    categories: {
      type: Array,
      default() {
        return []
      },
    },
  },
  methods: {
    itemClick(index) {
      this.myIndex = index
      this.$emit('itemClick', index)
    },
  },
  updated() {
    this.$refs.scroll.refresh()
  },
}
</script>
<style scoped>
.tabmenu {
  display: inline-block;
  height: calc(100vh - 88px);
  width: 90px;
  background-color: #f6f6f6;
  box-sizing: border-box;
}
.item {
  height: 45px;
  line-height: 45px;
  text-align: center;
  font-size: 14px;
}
.active {
  font-weight: 700;
  color: var(--color-high-text);
  background-color: #fff;
  border-left: 3px solid var(--color-high-text);
}
</style>
